﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zad4
{
    class Student
    {
        private string firstname;
        private string lastName;
        int age;

        public Student(string first, string last, int age)
        {
            this.firstname = first;
            this.lastName = last;
            this.age = age;
        }

        public string Firstname
        {
            get
            {
                return this.firstname;
            }
        }

        public string LastName
        {
            get
            {
                return this.lastName;
            }
        }

        public int Age
        {
            get
            {
                return this.age;
            }
        }

        public override string ToString()
        {
            return string.Format("{0} {1} -> {2} years old", this.Firstname, this.LastName, this.age);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Student[] collection = { new Student("Andrey", "Kamenov", 23), new Student("Andrey", "Andreev", 15), new Student("Momchil", "Namenov", 21) };
            var allBetween18And24 =
                from student in collection
                where (student.Age < 24 && student.Age > 18)
                select new { firstname = student.Firstname, lastname = student.LastName };
            foreach (var item in allBetween18And24)
            {
                Console.WriteLine(item);
            }
        }
    }
}
